﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace SharePointUtilitiesForDevelopers.Actions
{
    public partial class ContentTypeForm : Form
    {
        public SharePointWeb Web { get; set; }
        public List<SharePointField> ContentTypeFields { get; set; }
        public string ContentTypeName
        {
            get { return contentTypeNameTextBox.Text; }
            set { contentTypeNameTextBox.Text = value; }
        }

        public string ContentTypeDescription
        {
            get { return contentTypeDescriptionTextBox.Text; }
            set { contentTypeDescriptionTextBox.Text = value; }
        }

        public ContentTypeForm()
        {
            InitializeComponent();
        }

        private void ContentTypeForm_Load(object sender, EventArgs e)
        {
            BindContentTypeFields();
        }

        private void BindContentTypeFields()
        {
            foreach(var field in ContentTypeFields)
            {
                var lvItem = new ListViewItem(field.DisplayName);
                lvItem.Tag = field;
                lvItem.SubItems[0].Text = field.StaticName;
                contentTypeFieldsListView.Items.Add(lvItem);
            }
        }
    }
}